const joi = require('joi')

const username = joi.string().alphanum().min(1).max(10).required()
const password = joi.string().pattern(/^[\S]{6,12}$/).required()

const id = joi.number().integer().min(1).required()
const mickname = joi.string().required()
const email = joi.string().email().required()

const avatar =joi.string().dataUri().required()
// 以下暴露的子对象body内的属性都应该是 a:a 因为属性与值重名 所以简写了
exports.reg_login_schema = {
    body: {
        username,
        password
    }
}
exports.update_userinfo_schema = {
    body: {
        id,
        mickname,
        email

    }
}
exports.update_password_schema = {
    body: {
        oldPwd: password,
        newPwd: joi.not(joi.ref('oldPwd')).concat(password)
       
    }
}
exports.update_avatar_schema = {
    body:{
        avatar
    }
}